package bb.lanxing.adapter.sport;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

import bb.lanxing.R;

public class SportRecordDataAdapter extends RecyclerView.Adapter<SportRecordDataAdapter.ViewHolder> {
    private Context mContext;
    private List<String> valueList;
    private List<String> nameList;

    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView value;
        TextView name;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            value = itemView.findViewById(R.id.value);
            name = itemView.findViewById(R.id.name);
        }
    }

    public SportRecordDataAdapter(List<String> valueList, List<String> nameList) {
        this.valueList = valueList;
        this.nameList = nameList;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        mContext = parent.getContext();
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_sport_record_data, parent, false);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.value.setText(valueList.get(position));
        holder.name.setText(nameList.get(position));
    }

    @Override
    public int getItemCount() {
        return valueList.size();
    }
}